﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using Ninject;

namespace WP7DSMClient.Services.RunTime
{
    /// <summary>
    /// Provides runtime login services.
    /// </summary>
    public class LoginService : ILoginService
    {
        #region Private members

        private bool _isLogged = false;

        #endregion
        
        #region Constructor
        
        /// <summary>
        /// Default constructor. Do nothing.
        /// </summary>
        public LoginService()
        {
        }
        
        #endregion
        
        #region ILoginService Members

        /// <summary>
        /// Indicates if the user is loggued.
        /// </summary>
        public bool IsLogged
        {
            private set
            {
                if (_isLogged != value)
                {
                    _isLogged = value;
                    RaisePropertyChanged("IsLogged");
                }
            }
            get 
            { 
                return _isLogged; 
            }
        }

        /// <summary>
        /// Try to log the user.
        /// </summary>
        /// <param name="userName">UserName used to log in.</param>
        /// <param name="password">Password used to log in.</param>
        /// <returns><b>true</b> if the user is logged, <b>false</b> otherwise.</returns>
        public bool Log(string userName, string password)
        {

            object test = Application.Current.ApplicationLifetimeObjects[0];
            StandardKernelService s = StandardKernelService.Current;
            return IsLogged;
        }

        #endregion

        #region INotifyPropertyChanged Members

        /// <summary>
        /// Exposes the event for notifying a property change.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged == null) return;
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion
    }
}
